﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>




<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <title>雪场地图_我要滑雪网</title>
    <meta name="description" content="雪场地图" />
    <meta name="keywords" content="雪场地图" />
    <meta name="robots" content="all" />
    <link href="~/Css/ski.css" type="text/css" rel="stylesheet" />
    <link href="~/Css/style_zc.css" style="text/css" rel="stylesheet" />
    <link href="~/Css/public.css" style="text/css" rel="stylesheet" />
    <link href="~/Css/about.css" style="text/css" rel="stylesheet" />

    <script src="~/Js/Mobile device_style.js"></script>
    <script src="~/Js/jqueryhelp.js"></script>
    <script type="text/javascript" src="~/Js/tab.js"></script>
    <script src="~/Js/common.js" language="javascript"></script>


</head>
<base target="_self" />
<body>

    <div class="header">
        <div class="welcome">51SKI.COM 欢迎您</div>
    </div>
    <div class="wrap_zong">
        <div class="top">
            <div class="logo"><a href="/Home/Index" target="_self"><img src="http://img.51ski.com/images/logo-x.png" /></a></div>
            <div class="search">

                <form id="searchform" name="searchform" onsubmit="newsearch()">
                    <p class="p3">
                        <span class="jiaocheng_dj">雪场</span>
                        <input type="text" name="key" value="请输入雪场关键词" id="searchkey" />            <input type="submit" value="" class="submit" />
                    </p>
                    <div class="xiaxuan">
                        <span class="xuechang">雪场</span>
                        <span class="zixun">资讯</span>
                    </div>
                </form>


                <p class="p2"><span>|</span><a href="javascript:void(0)" class="shouji">手机版</a></p>

                <p class="p1"><span id="usernamespan" style="display:none"><a id="userName" href="/Home/Snow_Users"></a></span></p>


                <p class="p1"><a href="/Home/Snow_Users_Register">注册</a><span>|</span><a id="logoutspan" href="/Home/Snow_Users"><b class="color_red">登录</b></a></p>



                <p class="p4">
                    <a href="#">教学课程</a><a href="#">戏雪</a><a href="#">滑雪</a><a href="#">单板</a><a href="#">雪票预订</a>
                </p>

            </div>
            <ul class="nav">
                <li><a href="/Home/Snow_Map">雪场地图</a></li>
                <li><a href="/Home/News_Information">新闻资讯</a></li>
                <li><a href="/Home/Snow_Activity">雪场活动</a></li>
                <li><a href="/Home/Snow_Ticket">雪票预订</a></li>
                <li><a href="/Home/Snow_Course">滑雪教程</a></li>
                <li><a href="/Home/Snow_Video">酷炫视频</a></li>
                <li><a href="/Home/Snow_Users">用户中心</a></li>
            </ul>
        </div>
        <link rel="stylesheet" type="text/css" href="~/Css/jquery-ui.min.css">
        <script src="~/Js/jsondata.js"></script>
        <script src="~/Js/auth.js"></script>
        <script src="~/Js/newsearch.js">
        </script>
        <script src="~/Js/jquery-ui.min.js"></script>
        <script>
login();
var keyval = "雪场";
$(".xiaxuan").find("span").click(function(){
   keyval=$(this).html();
   if(keyval=="资讯"){
      $("#searchkey").val("请输入搜索内容");
   }else{
      $("#searchkey").val("请输入雪场关键词");
   }
});
    $("#searchkey").autocomplete({

	// 静态的数据源
    source: htmllist,
	select: function(event, ui){
		// event参数是事件对象
		$("#searchkey").val( ui.item.label);
		// 必须阻止默认行为，因为autocomplete默认会把ui.item.value设为输入框的value值
		event.preventDefault();
	}
	});
        </script>
        <div class="bannerBox">
            <style rel="stylesheet">
                ul, li, img, dl, dt, dd, p {
                    margin: 0;
                    padding: 0;
                    border: 0;
                    list-style: none;
                }

                #skiResortList {
                    overflow: hidden;
                    margin-top: 20px;
                }

                .pic_list {
                    overflow: hidden;
                    margin-top: 10px;
                }

                    .pic_list li {
                        width: 174px;
                        border: 1px solid #e0e0e0;
                        float: left;
                        padding: 2px 2px 3px;
                        background: #fff;
                        margin-bottom: 20px;
                        -moz-box-sizing: border-box;
                        box-sizing: border-box;
                        position: relative;
                        z-index: 1;
                        text-align: center;
                        margin-right: 29px;
                        *margin-right: 21px;
                        overflow: hidden;
                    }

                        .pic_list li a {
                            display: block;
                            line-height: 0;
                            overflow: hidden;
                        }

                        .pic_list li img {
                            display: inline-block;
                            width: 168px;
                            height: 150px;
                        }

                        .pic_list li h4 {
                            line-height: 20px;
                            margin: 0;
                            /*height: 24px;*/
                            height: 40px;
                            background: #f9f9f9;
                            font-size: 14px;
                            color: #666;
                            font-family: "微软雅黑";
                            padding: 16px 6px 2px;
                            font-weight: normal;
                        }

                #newsList dl {
                    overflow: hidden;
                    margin-bottom: 30px;
                }

                #newsList dt {
                    float: left;
                    position: relative;
                }

                    #newsList dt p {
                        font-size: 12px;
                        color: #fff;
                        width: 152px;
                        height: 29px;
                        position: absolute;
                        bottom: 0;
                        left: 0;
                        line-height: 29px;
                        padding-left: 8px;
                        background: #000;
                        filter: alpha(opacity=70);
                        opacity: 0.7;
                    }

                        #newsList dt p span {
                            float: left;
                        }

                        #newsList dt p .label {
                            float: right;
                            width: 32px;
                            height: 29px;
                            background: url("http://img.51ski.com/images/o_laber_sp_bg.fw.png");
                        }

                #newsList dd {
                    float: right;
                    width: 200px;
                }

                    #newsList dd a {
                        color: #000000;
                        font-size: 14px;
                        text-decoration: none;
                        font-family: "微软雅黑";
                    }

                        #newsList dd a h4 {
                            padding: 0;
                            margin: 0;
                            font-size: 14px;
                        }

                    #newsList dd p {
                        font-size: 12px;
                        color: #333;
                        margin: 3px 0;
                    }

                    #newsList dd em {
                        font-size: 12px;
                        color: #a9a9a9;
                    }

                #newsList dt a {
                    display: block;
                    line-height: 0;
                }

                .search_p {
                    height: 48px;
                    border-bottom: 1px solid #eee;
                }

                    .search_p span, .search_p input {
                        float: left;
                    }

                    .search_p .sp_l {
                        width: 4px;
                        height: 30px;
                        background: url("http://img.51ski.com/images/sp_l_bg.gif");
                    }

                    .search_p input {
                        color: #B8BDC0;
                        width: 335px;
                        padding: 0 7px;
                        height: 30px;
                        line-height: 30px;
                        background: url("http://img.51ski.com/images/search_input_bg.gif") repeat-x;
                        border: 0;
                    }

                    .search_p .sp_r {
                        width: 32px;
                        height: 30px;
                        background: url("http://img.51ski.com/images/sp_r_bg.gif");
                        cursor: pointer;
                    }

                .nav_apage {
                    color: #a3aaae;
                    font-size: 12px;
                }

                .nav_a {
                    height: 46px;
                    line-height: 44px;
                    color: #a3aaae;
                    font-size: 12px;
                    font-family: "宋体";
                    color: #b8bdc0;
                }

                    .nav_a .span_a_l {
                        float: left;
                    }

                    .nav_a .span_a_r {
                        float: right;
                    }

                    .nav_a span i {
                        font-style: normal;
                        color: #0073b9;
                    }

                .span_a_r i b {
                    background: url("http://img.51ski.com/images/i_paixu_bg.gif") no-repeat center center;
                    padding: 6px;
                    margin-right: 11px;
                }

                .xcxghd {
                    height: 39px;
                    background: url("http://img.51ski.com/images/xcxghd_bg.gif") repeat-x;
                    margin: 0;
                    padding: 0;
                    margin-bottom: 10px;
                }

                    .xcxghd p {
                        height: 39px;
                        background: url("http://img.51ski.com/images/xcxghd_title.png") no-repeat 12px 10px;
                    }

                .newsList2 dd a h4 {
                    color: #0373b3;
                }

                .map_nav {
                    height: 48px;
                    border: 1px solid #ededed;
                    background: #fafafa;
                    box-shadow: 0px 0px 5px #888;
                    position: relative;
                    z-index: 1;
                }

                    .map_nav li {
                        float: left;
                        text-align: center;
                        line-height: 48px;
                        background: #f3f3f3;
                        border-right: 1px solid #e2e2e2;
                        font-size: 14px;
                        color: #777777;
                        cursor: pointer;
                    }

                        .map_nav li:hover {
                            background: #fff;
                        }

                        .map_nav li.active {
                            background: #fff;
                        }

                .province_wrap {
                    background: #f6f6f6;
                    padding: 8px;
                    margin-bottom: 25px;
                }

                .province_h2 {
                    margin: 0;
                    border-bottom: 2px solid #007bce;
                    height: 28px;
                    font-size: 16px;
                    font-family: "微软雅黑";
                    color: #333;
                    padding-left: 14px;
                    position: relative;
                }

                    .province_h2 .triangle {
                        width: 0;
                        height: 0;
                        border-left: 6px solid transparent;
                        border-right: 6px solid transparent;
                        border-bottom: 6px solid #007bce;
                        position: absolute;
                        bottom: 0;
                        left: 30px;
                    }

                .nav_apage.span_a_r span:hover {
                    color: #ff8900;
                }

                .pop_w h3 {
                    background: transparent url("http://img.51ski.com/images/pop_h3.fw.png") no-repeat scroll 6px center;
                    text-align: center;
                    font-size: 16px;
                    font-family: "微软雅黑";
                    font-weight: normal;
                    white-space: nowrap;
                    padding: 0 25px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                }

                .pop_w div {
                    height: 91px;
                    margin: 6px 0;
                    border-radius: 1px;
                }

                    .pop_w div a {
                        display: block;
                        line-height: 0px;
                        border: 1px solid #b2b2b2;
                        height: 100%;
                    }

                        .pop_w div a img {
                            width: 100%;
                            height: 100%;
                        }

                .pop_w p {
                    font-size: 12px;
                    color: #000;
                    line-height: 22px;
                    height: 22px;
                }
            </style>


            <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=NlkCSXfGiVMY5lCVNW1RAqCa"></script>
            <script src="http://admin.51ski.com/js/underscore-min.js"></script>

            <script type="text/javascript"
                    src="~/Js/TextIconOverlay_min.js"></script>
            <script type="text/javascript"
                    src="~/Js/MarkerClusterer_min.js"></script>
            <script src="~/Js/jquery.easyui.min.js"></script>
            <script src="~/Js/packs.js"></script>
            <div style="width:1200px;overflow:hidden;margin:0 auto;margin-top:10px;">
                <div style="float:left;width:800px;overflow:hidden;">
                    <ul class="map_nav">
                        <li id="dongbei" class="active">东北地区</li>
                        <li id="huabei">华北地区</li>
                        <li id="xibei">西北地区</li>
                        <li id="huadong">华东地区</li>
                        <li id="huazhong">华中地区</li>
                        <li id="xinan">西南地区</li>
                        <li id="quanguo">全国雪场</li>
                    </ul>
                    <script>
	var parentWidth = $(".map_nav").width();
	var liLength = $(".map_nav li").length;
	$(".map_nav li").width(((parentWidth-liLength)/liLength));
	$(".map_nav li").last().css("border-right",0);
	var map_diqu;//用户所处地区，全局变量
    $(".map_nav li").click(function(){
		$(this).addClass("active").siblings().removeClass("active");
		map_diqu = $(this).attr("id");
			switch (map_diqu){
		  case "dongbei": map.centerAndZoom(new BMap.Point(125.33017, 43.82178), 8);
			break;
		  case "huabei": map.centerAndZoom(new BMap.Point(116.413554, 39.911013), 8);
			break;
		  case "xibei": map.centerAndZoom(new BMap.Point(87.604917, 43.832598), 8);
			break;
		  case "huadong": map.centerAndZoom(new BMap.Point(117.199214,34.284386), 8);
			break;
		  case "huazhong": map.centerAndZoom(new BMap.Point(113.631349, 34.753488), 8);
			break;
		  case "xinan": map.centerAndZoom(new BMap.Point(104.071216,30.665534), 8);
			break;
		  default: map.centerAndZoom(new BMap.Point(116.413554, 39.911013), 8);
			}
		if(map_diqu == "quanguo"){
			showAllResort(10);
			}else{
			showAreaResort(8);
			}
		})
                    </script>
                    <div id="container" style="width: 800px;height: 600px;"></div>
                    <div id="skiResortList"></div>

                </div>
                <div style="float:right;width:386px;">
                    <p class="search_p"><span class="sp_l"></span><input type="text" placeholder="请输入雪场名称或关键字" id="searchText"><span class="sp_r"></span></p>
                    <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
                    <p class="nav_a">
                        <span class="span_a_l">雪场地图 > 新闻活动</span><span class="nav_apage span_a_r">
                            共 <span id="page_all">0</span> 页 第 <span id="page_curr">0</span> 页  <span style="cursor:pointer;" onclick="prePangNews()">上一页 </span><span style="cursor:pointer;" onclick="nextPangNews()">下一页</span>
                            <input type="hidden" value="0" id="page_curr_num" />
                        </span>
                    </p>


                    <div id="newsList">

                    </div>
                </div>
            </div>


            <script type="text/javascript">
    var city = '';
    var province = '';
    var splitLevel = 8;

    var map = null;
    var markerClusterer = null;

	var proviceMap = {}
	proviceMap['辽宁省'] = 'dongbei';
	proviceMap['吉林省'] = 'dongbei';
	proviceMap['黑龙江省'] = 'dongbei';

	proviceMap['北京市'] = 'huabei';
	proviceMap['天津市'] = 'huabei';
	proviceMap['河北省'] = 'huabei';
	proviceMap['山西省'] = 'huabei';
	proviceMap['内蒙古自治区'] = 'huabei';

	proviceMap['陕西省'] = 'xibei';
	proviceMap['甘肃省'] = 'xibei';
	proviceMap['青海省'] = 'xibei';
	proviceMap['宁夏回族自治区'] = 'xibei';
	proviceMap['新疆维吾尔自治区'] = 'xibei';

	proviceMap['上海市'] = 'huadong';
	proviceMap['江苏省'] = 'huadong';
	proviceMap['浙江省'] = 'huadong';
	proviceMap['安徽省'] = 'huadong';
	proviceMap['江西省'] = 'huadong';
	proviceMap['山东省'] = 'huadong';
	proviceMap['福建省'] = 'huadong';

	proviceMap['河南省'] = 'huazhong';
	proviceMap['湖北省'] = 'huazhong';
	proviceMap['湖南省'] = 'huazhong';


	proviceMap['广东省'] = 'huazhong';//华南没有雪场，定位华中地区
	proviceMap['广西壮族自治区'] = 'huazhong';
	proviceMap['海南省'] = 'huazhong';
	proviceMap['香港特别行政区'] = 'huazhong';
	proviceMap['澳门特别行政区'] = 'huazhong';
	proviceMap['台湾省'] = 'huazhong';

	proviceMap['重庆市'] = 'xinan';
	proviceMap['四川省'] = 'xinan';
	proviceMap['贵州省'] = 'xinan';
	proviceMap['云南省'] = 'xinan';
	proviceMap['西藏自治区'] = 'xinan';

	var dongbei = "辽宁省,吉林省,黑龙江";
	var huabei = "北京市,天津市,河北省,山西省,内蒙古自治区";
	var xibei = "陕西省,甘肃省,青海省,宁夏回族自治区,宁  夏,新  疆,新疆维吾尔自治区";
	var huadong = "上海市,江苏省,浙江省,安徽省,江西省,山东省,福建省";
	var huazhong = "河南省,湖北省,湖南省";
	var huanan = "广东省,广西壮族自治区,海南省,香港特别行政区,澳门特别行政区,台湾省";
	var xinan = "重庆市,四川省,贵州省,云南省,西藏自治区";
	var quanguo = "辽宁省,吉林省,黑龙江,北京市,天津市,河北省,山西省,内蒙古自治区,陕西省,甘肃省,青海省,宁夏回族自治区,宁  夏,新  疆,新疆维吾尔自治区,上海市,江苏省,浙江省,安徽省,江西省,山东省,福建省,河南省,湖北省,湖南省,广东省,广西壮族自治区,海南省,香港特别行政区,澳门特别行政区,台湾省,重庆市,四川省,贵州省,云南省,西藏自治区";

    $.ajax({
        url: 'http://api.map.baidu.com/location/ip?ak=NlkCSXfGiVMY5lCVNW1RAqCa',
        type: 'POST',
        dataType: 'jsonp',
        async: true,
        jsonpCallback: "success_jsonpCallback",
        success: function (data) {
            map = new BMap.Map("container", {minZoom: 5});

            map.addControl(new BMap.MapTypeControl({
                mapTypes: [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP]
            }));
            map.addControl(new BMap.NavigationControl());
            map.enableScrollWheelZoom();
            map.enableContinuousZoom();
            map.centerAndZoom(city, 8);

            map.addEventListener('dragend', function (e) {
                showSkiResort(splitLevel);
            });

            map.addEventListener('zoomend', function () {
                showSkiResort(splitLevel);
            });

			showSkiResort(8);//初始化雪场及新闻列表
        }
    });
	//雪场搜索
	function G(id) {
		return document.getElementById(id);
	}
	var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
		{"input" : "searchText"
		,"location" : map
	});

	ac.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
	var str = "";
		var _value = e.fromitem.value;
		var value = "";
		if (e.fromitem.index > -1) {
			value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		}
		str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

		value = "";
		if (e.toitem.index > -1) {
			_value = e.toitem.value;
			value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		}
		str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
		G("searchResultPanel").innerHTML = str;
	});

	var myValue;
	ac.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
	var _value = e.item.value;
		myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;

		setPlace();
	});

	function setPlace(){
		map.clearOverlays();    //清除地图上所有覆盖物
		function myFun(){
			var pp = local.getResults().getPoi(0).point;    //获取第一个智能搜索的结果
			map.centerAndZoom(pp, 18);
			map.addOverlay(new BMap.Marker(pp));    //添加标注
		}
		var local = new BMap.LocalSearch(map, { //智能搜索
		  onSearchComplete: myFun
		});
		local.search(myValue);
	}

	//初始化地区新闻
    function initNewsList(diqu,pagenum)
    {
		if(pagenum < 0) pagenum = 0;
		map_diqu = diqu;//重要，切换雪场和地区
        var apiUrl = 'http://www.51ski.com/static/packnews/'+diqu+'_'+pagenum+'.js';//'http://www.51ski.com/static/packnews/100001400_0.inc';//'http://www.51ski.com/static/packnews/' + skiResort.id + '_0.js';
        $.ajax({
            url: apiUrl,
            type: 'GET',
            dataType:'json',
            success: function (data) {
                var html = "<ul>";
                for (var i = 0; i < data.data.length; i++) {
                    var news = data.data[i];
                    html += buildNewsHtml(news);
                }

                html += "</ul>";
				$("#page_all").html(data.rows);
				$("#page_curr").html(parseInt(pagenum)+1);
				document.getElementById("page_curr_num").value = parseInt(pagenum)+1;
                document.getElementById("newsList").innerHTML = html;
				substri_text();//限制新闻摘要的字数
            }
        });
    }
	//新闻下一页
	function nextPangNews(){
		initNewsList(map_diqu,$("#page_curr").text());
	}
	//新闻上一页
	function prePangNews(){
		var tmp_curr = document.getElementById("page_curr_num").value;
		initNewsList(map_diqu,tmp_curr - 2);
	}


    function success_jsonpCallback(data) {
        province = data.content.address_detail.province;
        city = data.content.address_detail.city;
    }
	//根据经纬度加载所属地区新闻
	function ret_province(){
	var center_lat = map.getCenter().lat;
	var center_lng = map.getCenter().lng;
		$.ajax({
        url: 'http://api.map.baidu.com/geocoder/v2/?ak=NlkCSXfGiVMY5lCVNW1RAqCa&location='+center_lat+','+center_lng+'&output=json&pois=0',
        type: 'POST',
        dataType: 'jsonp',
        async: true,
        success: function (data) {
          province = data.result.addressComponent.province;
		  //alert(province)
		  for(var prop in proviceMap){
			if(prop == province){
				initNewsList(proviceMap[prop],0);
				map_diqu = proviceMap[prop];//地区变量设定值
			}
			}
        }
    });
	}

	 function showAreaResort(sLevel) {
		ret_province();

		var containArray;
		var area_prov;
		switch (map_diqu){
		  case "dongbei": area_prov = dongbei;
			break;
		  case "huabei": area_prov = huabei;
			break;
		  case "xibei": area_prov = xibei;
			break;
		  case "huadong": area_prov = huadong;
			break;
		  case "huazhong": area_prov = huazhong;
			break;
		  case "xinan": area_prov = xinan;
			break;
		  default: area_prov = huabei;
			}

		//alert('area_prov:'+area_prov);
		containArray = _.filter(jsondata, function (sr) {
            return area_prov.indexOf(sr.province) > -1;
        });

        clearOverlay();

        if (markerClusterer != null)
            markerClusterer.clearMarkers();

        var level = map.getZoom();
        if (level < sLevel) {
            var markers = [];
            var pt = null;
            for (var i = 0; i < containArray.length; i++) {
                var sr = containArray[i];
                pt = new BMap.Point(sr.geogeaphic_longitude, sr.geogeaphic_latitude);
                markers.push(new BMap.Marker(pt));
            }
            //最简单的用法，生成一个marker数组，然后调用markerClusterer类即可。
            markerClusterer = new BMapLib.MarkerClusterer(map, {markers: markers});
        }
        else {
            for (var i = 0; i < containArray.length; i++) {
                var sr = containArray[i];
                var point = new BMap.Point(sr.geogeaphic_longitude, sr.geogeaphic_latitude);
                var myIcon = new BMap.Icon("http://img.51ski.com/images/Ski.png", new BMap.Size(22,36));
                var marker = new BMap.Marker(point,{icon:myIcon});  // 创建标注
                //var marker = new BMap.Marker(point);  // 创建标注
                map.addOverlay(marker);              // 将标注添加到地图中

                addClickHandler(sr, marker);
            }

            addSkiResort2List(containArray);
        }
    }

function showAllResort(sLevel) {
		ret_province();

		var containArray;
		var area_prov = quanguo;

		containArray = _.filter(jsondata, function (sr) {
            return area_prov.indexOf(sr.province) > -1;
        });
        clearOverlay();

        if (markerClusterer != null)
            markerClusterer.clearMarkers();

            var markers = [];
            var pt = null;
            for (var i = 0; i < containArray.length; i++) {
                var sr = containArray[i];
                pt = new BMap.Point(sr.geogeaphic_longitude, sr.geogeaphic_latitude);
                markers.push(new BMap.Marker(pt));
            }
            //最简单的用法，生成一个marker数组，然后调用markerClusterer类即可。
            markerClusterer = new BMapLib.MarkerClusterer(map, {markers: markers});
			addSkiResort2List(containArray);

    }

    function showSkiResort(sLevel) {
		ret_province()
        var bounds = map.getBounds();
        var wsPoint = bounds.getSouthWest();
        var enPoint = bounds.getNorthEast();

        var containArray = _.filter(jsondata, function (sr) {
            return wsPoint.lng < sr.geogeaphic_longitude && sr.geogeaphic_longitude < enPoint.lng && wsPoint.lat < sr.geogeaphic_latitude && sr.geogeaphic_latitude < enPoint.lat;
        });

        clearOverlay();

        if (markerClusterer != null)
            markerClusterer.clearMarkers();

        var level = map.getZoom();
        if (level < sLevel) {
            var markers = [];
            var pt = null;
            for (var i = 0; i < containArray.length; i++) {
                var sr = containArray[i];
                pt = new BMap.Point(sr.geogeaphic_longitude, sr.geogeaphic_latitude);
                markers.push(new BMap.Marker(pt));
            }
            //最简单的用法，生成一个marker数组，然后调用markerClusterer类即可。
            markerClusterer = new BMapLib.MarkerClusterer(map, {markers: markers});
        }
        else {
            for (var i = 0; i < containArray.length; i++) {
                var sr = containArray[i];
                var point = new BMap.Point(sr.geogeaphic_longitude, sr.geogeaphic_latitude);
                var myIcon = new BMap.Icon("http://img.51ski.com/images/Ski.png", new BMap.Size(22,36));
                var marker = new BMap.Marker(point,{icon:myIcon});  // 创建标注
                //var marker = new BMap.Marker(point);  // 创建标注
                map.addOverlay(marker);              // 将标注添加到地图中

                addClickHandler(sr, marker);
            }

            addSkiResort2List(containArray);
        }
    }

	//绘制地图底部的雪场信息
    function addSkiResort2List(srArray) {
	var arrayList = new Array();
	for (var k = 0; k < srArray.length; k++) {
		var sr = srArray[k];
		arrayList[k] = sr.province;
//		alert(arrayList[k]);
	}
	arrayList = _.union(arrayList);
//	alert(arrayList.length);

	var html = "";
	for(var j = 0; j < arrayList.length; j++){
		var str_provin = arrayList[j];
		html += "<div class='province_wrap'><h2 class='province_h2'>"+str_provin+"<span class='triangle'></span></h2><ul class='pic_list'>"
		 for (var i = 0; i < srArray.length; i++) {
            var sr = srArray[i];
			if(sr.province == str_provin){
			var liHtml = "<li>";
            liHtml += "<a target='_blank' href='" + sr.homepage + "'><img src='" + sr.cover_pack + "'/></a>";
 liHtml += "<a target='_blank' href='" + sr.homepage + "'><h4>" + sr.pack_name + "</h4></a>";
            liHtml += "</li>";
            html += liHtml;
			}
        }
			html +="</ul></div>";
	}
        document.getElementById("skiResortList").innerHTML = html;
		clearMargin();
    }

	function clearMargin(){
        $(".pic_list li:nth-child(4n)").css({
			"margin-right":"0px"
			})
         }

    function buildPopMsg(skiR) {
        var html = "<div class=\"pop_w\">"
        html += "<h3>" + skiR.pack_name +"</h3>";
		html += "<div><a href="+ skiR.homepage +"><img src="+ skiR.cover_pack +"></a></div>";
		html += "<p>营业时间："+skiR.snow_start.substring(0,10)+" ~ "+skiR.snow_end.substring(0,10)+"</p>";
		html += "<p>海拔："+skiR.lowest_altitude+"米 ~ "+skiR.altitude+"米</p>";
		html += "</div>";
        return html;
    }

    function addClickHandler(skiResort, marker) {
        marker.addEventListener("click", function (e) {

            openInfo(skiResort, e);
        });
    }

    function openInfo(skiResort, marker) {
        var p = marker.target;

        var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);

        var opts = {
            width: 233,     // 信息窗口宽度
            height: 175,     // 信息窗口高度
            title: skiResort.name, // 信息窗口标题
            enableMessage: true//设置允许信息窗发送短息
        };
        var infoWindow = new BMap.InfoWindow(buildPopMsg(skiResort), opts);  // 创建信息窗口对象

        map.openInfoWindow(infoWindow, point); //开启信息窗口

		initNewsList(skiResort.id,0);

    }

    function buildNewsHtml(newsInfo) {

        var html = "<li>";
        html += "<dl><dt><a href='" + newsInfo.url + "'><img style='width:160px;height: 120px;' src='" + newsInfo.pic + "'/><p>";
		html += "<span>" + newsInfo.title + "</span></p></a></dt>";
        html += "<dd><a href='" + newsInfo.url + "'><h4>" + newsInfo.title + "</h4></a>";
        html +="<em>"+newsInfo.time+"</em>";
        html +="<p>"+newsInfo.abstract+"</p></dd></dl>";
        html+="</li>";
        return html;
    }

    function clearOverlay() {
        map.clearOverlays();
    }
	function substri_text(){
	$("#newsList dd p").each(function(){
					ywz=$(this).text()
					xwz=ywz.substr(0,40) + "……";
					$(this).text(xwz);
					$(this).attr("title",ywz)
				  });
	}

            </script>
        </div>
        <div class="zx_footer">

            <ul>
                <li>
                    <img src="http://img.51ski.com/images/weibo_tuo1.png" />
                    <input type="button" value="进入官方微博" onclick="window.open('http://weibo.com/51ski/profile?s=6cm7D0')" />
                </li>
                <li>
                    <img src="http://img.51ski.com/images/weixin_tuo1.png" />
                    <input type="button" value="扫一扫立即注册" />
                </li>
            </ul>
            <div class="erweima">
                <img src="http://img.51ski.com/images/erweima.png" />
            </div>
            <div class="foot_con">
                <p><a href="http://www.51ski.com/aboutus/">关于我们</a><span>|</span><a href="http://www.51ski.com/law/">法律声明</a><span>|</span><a href="http://www.51ski.com/joinus/">加入我们</a><span>|</span><a href="http://www.51ski.com/coop/">合作雪场</a><span>|</span><a href="http://www.51ski.com/connection/">联系我们</a></p>
                <p>&copy;Copyright    1996-2014 51SKI  Corporation, All Rights Reserved</p>
                <p><a href="http://www.miitbeian.gov.cn/publish/query/indexFirst.action">51SKI 京公网安备11010102001739号/京ICP备15016851号-4</a></p>
                <p>我要滑雪网   版权所有 </p>
            </div>

        </div>
        <script type="text/javascript">
try{
var _ourplusPageurl = top.location.href;
}catch(e)
{
var _ourplusPageurl = location.href;
}
document.getElementById("logoutspan").href = "http://www.51ski.com/login/index.html?reurl=" + _ourplusPageurl;
        </script>
        <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?3bbc0e16ff36039bc4d0e85091a39c71";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
        </script>

    </div>
</body>

</html>
